package com.usain.dataconverter;



import com.usain.utils.DateUtils;
import org.springframework.core.convert.converter.Converter;

import java.util.Date;

public class DataConverter implements Converter<String, Date> {


    @Override
    public Date convert(String str) {
        String[] patterns = new String[]{
                "yyyy-MM-dd","yyyy-MM-dd hh:mm:ss","yyyy/MM/dd","yyyy/MM/dd hh:mm:ss",
                "MM-dd-yyyy","dd-MM-yyyy"};

        try {
            Date date = DateUtils.stringToDate(str,"yyyy-MM-dd");
            return date;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
